package admin.board.category.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import util.SqlMapLocator;

import admin.board.category.dto.CategoryDto;

public class CategoryDao {
	private static CategoryDao instance;
	public static CategoryDao getInstance() {
		if(instance == null) {
			instance = new CategoryDao();
		}
		
		return instance; 
	}
	private CategoryDao() {}
	
	@SuppressWarnings("unchecked")
	public List<CategoryDto> list() throws SQLException {
		return (List<CategoryDto>)SqlMapLocator.getMapper().queryForList("category.list");
	}
	
	public CategoryDto selectOne(int category_no) throws SQLException {
		return (CategoryDto)SqlMapLocator.getMapper().queryForObject("category.selectOne", category_no); 
	}
	
	public void insert(CategoryDto dto) throws SQLException {
		SqlMapLocator.getMapper().insert("category.insert", dto);
	}
	
	public void delete(int category_no) throws SQLException {
		SqlMapLocator.getMapper().delete("category.delete", category_no);
	}
	
	@SuppressWarnings("rawtypes")
	public void update(CategoryDto dto) throws SQLException {
		SqlMapLocator.getMapper().update("category.update", dto);
	}
}
